home *** CD-ROM | disk | FTP | other *** search
/ Champak 120 / Vol 120.iso / games / anacroz.swf / scripts / __Packages / Flecha.as next >
Text File  |  2010-11-09  |  2KB  |  37 lines

  1. class Flecha
  2. {
  3.    function Flecha(tilex0, tiley0, tilex1, tiley1, id, quem, mcnome, forca)
  4.    {
  5.       this.ativa = true;
  6.       var _loc5_ = (this.destinox = tilex1) - tilex0;
  7.       var _loc4_ = (this.destinoy = tiley1) - tiley0;
  8.       this.cz = -24;
  9.       this.fx = 40 * (_loc5_ + _loc4_) / (this.ft = Math.sqrt(_loc5_ * _loc5_ + _loc4_ * _loc4_) * 4);
  10.       this.fy = 20 * (tiley1 - tilex1 + tilex0 - tiley0) / this.ft;
  11.       this.t = (12 * this.ft - Math.sqrt(144 * this.ft * this.ft - 1152 * this.ft)) / 24;
  12.       this.id = id;
  13.       this.forca = forca;
  14.       this.quem = quem;
  15.       _root.attachMovie(mcnome,"f1" + id,3000 + id);
  16.       _root["f1" + id]._visible = false;
  17.       _root["f1" + id]._x = this.cx = 40 * (tilex0 + tiley0) - 240;
  18.       _root["f1" + id]._y = this.cy = 305 + (tiley0 - tilex0) * 20;
  19.    }
  20.    function atualizar()
  21.    {
  22.       this.cz = this.forca * ((- this.ft) * this.t + this.t * this.t) / this.ft;
  23.       if(this.cz > 0)
  24.       {
  25.          this.ativa = false;
  26.          _root.flechadano(this.id,this.destinox,this.destinoy,this.quem);
  27.          removeMovieClip(_root["f1" + this.id]);
  28.          return undefined;
  29.       }
  30.       _root["f1" + this.id]._rotation = 180 * Math.atan2(this.fy + this.forca * (2 * this.t + 1 - this.ft) / this.ft,this.fx) / 3.141592653589793;
  31.       _root["f1" + this.id]._x = this.cx += this.fx;
  32.       _root["f1" + this.id]._y = (this.cy += this.fy) + this.cz;
  33.       _root["f1" + this.id]._visible = true;
  34.       this.t = this.t + 1;
  35.    }
  36. }
  37.